package nju.edu.super_scholar.PersonalInfoManage;

import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.RemoteException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nju.edu.super_scholar.enums.Gender;
import nju.edu.super_scholar.enums.School;
import nju.edu.super_scholar.vo.PersonalInfoVO;
import dataservice.PersonalInfoOp;

public class ModifyPersonalInfo extends HttpServlet{
	   String userID;  
	   String name; 
	   School school;
	   Gender gender;
	   String password;
		
		public void doPost(HttpServletRequest request, HttpServletResponse response)
	            throws ServletException, IOException {

	        response.setContentType("text/html;charset=utf-8");
	        request.setCharacterEncoding("utf-8");
	        response.setCharacterEncoding("utf-8");
	        PrintWriter out = response.getWriter();
	        
	        name= request.getParameter("newName");
	        school=School.valueOf(request.getParameter("newSchool"));
	        gender=Gender.valueOf(request.getParameter("newGender"));
	        userID=request.getParameter("userID");
	        password=request.getParameter("password");
	        
	        modify();
	        out.flush();
	        out.close();
}

		private  void modify(){
			PersonalInfoOp op=new PersonalInfoOp();
			try {
				op.modifyMyInfo(new PersonalInfoVO(userID, gender, school, name, null, 0, ""));
			} catch (RemoteException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
}